package com.acwing.partition21;

import java.io.*;
import java.math.BigInteger;

/**
 * @author `RKC`
 * @date 2022/3/11 10:55
 */
public class AC2068整数拼接_枚举 {

    private static final int N = 100010;
    private static int[] nums = new int[N];
    private static int n, k;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        n = Integer.parseInt(ss[0]);
        k = Integer.parseInt(ss[1]);
        BigInteger m = new BigInteger(String.valueOf(k));
        ss = reader.readLine().split(" ");
        for (int i = 0; i < n; i++) nums[i] = Integer.parseInt(ss[i]);
        int ans = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i == j) continue;
                BigInteger num = new BigInteger(nums[i] + "" + nums[j]);
                if (num.mod(m).intValue() == 0) ans++;
            }
        }
        writer.write(ans + "\n");
        writer.flush();
    }
}
